define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form, Layer) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'setting/config/index',
                    add_url: 'setting/config/add',
                    edit_url: 'setting/config/edit',
                    del_url: 'setting/config/del',
                    table: 'firm_config',
                }
            });

            var table = $("#table");

            // 为表格绑定事件
            Table.api.bindevent(table);

            Form.api.bindevent($("form#add-form"), null, function (ret) {
                setTimeout(function(){
                    location.reload();
                },1500);
            });
            $('#address').on('click', function(){
                // 禁用按钮防止重复提交
                // $("#address").attr({ disabled: "disabled" });//不加的话容易滑屏...
                //Layer.open({
                //    type: 2,
                //    title: '腾讯地图定位',
                //    maxmin: false,
                //    shadeClose: true, //点击遮罩关闭层
                //    area: ['550px', '100%'],
                //    content: ["/admin/map/index.html",'no'],
                //    yes: function(index){
                //        //打印返回的值，看是否有我们想返回的值。
                //        console.log(index);
                //    },
                //});
            });
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});